import requests
try:
    fw = open(r"C:\Users\Administrator\Desktop\photo.jpg", "wb")
    img = requests.get("http://n.sinaimg.cn/news/crawl/117/w550h367/20220417/a3a9-08b2ca6dffe4210149dda424adf0734f.jpg")
    for line in img:
        fw.write(line)
    fw.close()
    print("下载文件成功")
except IOError as e:
    print(e)
    print("下载文件失败")
